package com.dems.admin.controller;

import com.dems.admin.security.SecurityUtils;
import com.dems.dao.dataobject.ResRoom;
import com.dems.domain.JsonResponse;
import com.dems.domain.ResRoomReqVO;
import com.dems.service.ResRoomService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/resRoom")
public class ResRoomController {

    @Autowired
    private ResRoomService resRoomService;

    @PostMapping("/find")
    public JsonResponse findResRoomList(@RequestBody ResRoomReqVO resRoomReqVO) {
        return JsonResponse.success(resRoomService.find(resRoomReqVO));
    }

    @PostMapping("/findOne")
    public JsonResponse findOne(@RequestBody ResRoom resRoom){
        return JsonResponse.success(resRoomService.findOne(resRoom));
    }

    @PostMapping("/update")
    public JsonResponse updateResRoom(@RequestBody ResRoom resRoom){
        return JsonResponse.success(resRoomService.updateRoom(resRoom, SecurityUtils.getLoanassistUser()));
    }

    @PostMapping("/create")
    public JsonResponse createResRoom(@RequestBody ResRoom resRoom){
        return JsonResponse.success(resRoomService.createRoom(resRoom, SecurityUtils.getLoanassistUser()));
    }
}
